home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Periodicals / develop / develop 4 code / C++ Driver / iacDriver / DriverWrapper.cp < prev    next >
Encoding:
Text File  |  1990-08-27  |  5.4 KB  |  143 lines  |  [TEXT/MPS ]

  1. // Copyright © 1990 Apple Computer, Inc. All rights reserved.
  2. #ifndef __IACHeaders__            // Every source file which uses the headers defined
  3. #include    "IACHeaders.h"            // In the main header file get the file included.  
  4. #endif
  5.  
  6.  
  7. /**********************************Comment*****************************************
  8.  * TSDRVROpen is called by the assembly TSEOpen routine.  It in turn will just turn
  9.  *     around and call the TDriver::IACOpen method after some setup.
  10.  * This routine must instantiate the TDriver object.  We'll be good heap users
  11.  * and move the object (handle) hi.  If we get an error, we'll return
  12.  * MemErr, mostly for debugging purposes.  Declared as extern "C" in DriverWrapper.h
  13.  **********************************End Comment************************************/
  14.  
  15. OSErr     
  16. TSDRVROpen(ParmBlkPtr oParmBlock,DCtlPtr tsDCEPtr)
  17. {
  18. TDrvrPtr    aDrvrPtr;
  19. OSErr        err;
  20.  
  21. // Create TDriver object
  22. aDrvrPtr = new(TDriver);
  23.         
  24. // make dCtlStorage point to it.
  25. tsDCEPtr->dCtlStorage = (Handle) aDrvrPtr;    
  26. if(tsDCEPtr->dCtlStorage)
  27.     {
  28.     MoveHHi(tsDCEPtr->dCtlStorage);
  29.     HLock(tsDCEPtr->dCtlStorage);
  30.     aDrvrPtr = (TDrvrPtr) tsDCEPtr->dCtlStorage;
  31.     err = aDrvrPtr->iacOpen(oParmBlock);                    // Call the iacOpen() method.
  32.     HUnlock(tsDCEPtr->dCtlStorage);                                
  33.     return(err);                        
  34.     }
  35. else
  36.     return MemError();
  37. }
  38.  
  39. /**********************************Comment*****************************************
  40.  * TSDRVRPrime is called by the assembly TSEPrime routine.  It in turn will just turn
  41.  *     around and call the TDriver::IACPrime method after locking the object.
  42.  * This essentially just locks the handle whose master pointer points to the object,
  43.  * and then will call the appropriate method.  When done, it'll unlock the handle.
  44.  **********************************End Comment************************************/
  45.     OSErr        
  46. TSDRVRPrime(ParmBlkPtr pParmBlock,DCtlPtr tsDCEPtr)
  47. {
  48. TDrvrPtr    aDrvrPtr;
  49. OSErr        err;
  50.  
  51. HLock(tsDCEPtr->dCtlStorage);                                    // Lock the storage handle
  52. aDrvrPtr = (TDrvrPtr) tsDCEPtr->dCtlStorage;                // Object pointer = master pointer
  53. err = aDrvrPtr->iacPrime(pParmBlock);                        // Call the iacPrime() method.
  54. HUnlock(tsDCEPtr->dCtlStorage);                                // Unlock the handle.
  55. return(err);                                                        
  56. }
  57.  
  58.  
  59. /**********************************Comment*****************************************
  60.  * TSDRVRControl is called by the assembly TSEControl routine.  It in turn will just turn
  61.  *     around and call the TDriver::IACControl method after locking the object.
  62.  * This essentially just locks the handle whose master pointer points to the object,
  63.  * and then will call the appropriate method.  When done, it'll unlock the handle.
  64.  **********************************End Comment************************************/
  65.  
  66.     OSErr        
  67. TSDRVRControl(ParmBlkPtr cntlParmBlock,DCtlPtr tsDCEPtr)
  68. {
  69. TDrvrPtr    aDrvrPtr;
  70. OSErr        err;
  71.  
  72. HLock(tsDCEPtr->dCtlStorage);                                    // Lock the storage handle
  73. aDrvrPtr = (TDrvrPtr) tsDCEPtr->dCtlStorage;            // Object pointer = master pointer
  74. err = aDrvrPtr->iacControl(cntlParmBlock);                // Call the iacControl() method
  75. HUnlock(tsDCEPtr->dCtlStorage);                                // Unlock the handle.
  76. return(err);
  77. }
  78.  
  79.  
  80. /**********************************Comment*****************************************
  81.  * TSDRVRStatus is called by the assembly TSEStatus routine.  It in turn will just turn
  82.  *     around and call the TDriver::IACStatus method after locking the object.
  83.  * This essentially just locks the handle whose master pointer points to the object,
  84.  * and then will call the appropriate method.  When done, it'll unlock the handle.
  85.  **********************************End Comment************************************/
  86.  
  87.     OSErr        
  88. TSDRVRStatus(ParmBlkPtr sParmBlock,DCtlPtr tsDCEPtr)
  89. {
  90. TDrvrPtr    aDrvrPtr;
  91. OSErr        err;
  92.  
  93. HLock(tsDCEPtr->dCtlStorage);                                    // Lock the storage handle
  94. aDrvrPtr = (TDrvrPtr) tsDCEPtr->dCtlStorage;            // Object pointer = master pointer
  95. err = aDrvrPtr->iacStatus(sParmBlock);                        // Call the iaStatus() method
  96. HUnlock(tsDCEPtr->dCtlStorage);                                // Unlock the handle.
  97. return(err);                                                        
  98. }
  99.  
  100.  
  101. /**********************************Comment*****************************************
  102.  * TSDRVRClose is called by the assembly TSEClose routine.  It in turn will just turn
  103.  *     around and call the TDriver::IACClose method after locking the object.
  104.  * This essentially just locks the handle whose master pointer points to the object,
  105.  * and then will call the appropriate method.  When done, it'll unlock the handle, 
  106.  * and dispose of the handle created at open time.
  107.  **********************************End Comment************************************/
  108.  
  109.     OSErr        
  110. TSDRVRClose(ParmBlkPtr cParmBlock,DCtlPtr tsDCEPtr)
  111. {
  112. TDrvrPtr    aDrvrPtr;
  113. OSErr        err;
  114.  
  115. HLock(tsDCEPtr->dCtlStorage);                                // Lock the storage handle
  116. aDrvrPtr = (TDrvrPtr) tsDCEPtr->dCtlStorage;            // Object pointer = master pointer
  117. err = aDrvrPtr->iacClose(cParmBlock);                    // Call the iacClose() method
  118. HUnlock(tsDCEPtr->dCtlStorage);                            // Unlock the handle.
  119. delete(aDrvrPtr);                                                // Clean up after ourselves.
  120. return(err);
  121. }
  122.  
  123.  
  124.  
  125. /**********************************Comment*****************************************
  126.  * tseStrCpy is used by the TDriver and TMessage methods.  It simply takes a source
  127.  * string (s) and copies that to the destination string (d).  It returns the 
  128.  * destination string.
  129.  **********************************End Comment************************************/
  130. char*
  131. tseStrCpy(char *d,char *s)
  132. {
  133. short        i = 0;
  134.  
  135. while ( (i < 255) && (s[i] != kZeroChar) )
  136.     {
  137.     d[i] = s[i];
  138.     i++;
  139.     }
  140. d[i] = '\0';
  141. return (d);
  142. }
  143.